package cn.tedu.egmvc1.controller;

import cn.tedu.egmvc1.pojo.dto.UpdateDyo;
import cn.tedu.egmvc1.pojo.dto.UserDTO;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class User {
//用户将:用户名、密码、昵称 数据传递给服务端，服务端处理请求。
    @RequestMapping(value = "/v1/users/userList")
    @ResponseBody
    public String User(UserDTO userDTO){
        String Username = userDTO.getUsername();
        String Password = userDTO.getPassword();
        String NiekName = userDTO.getNiekName();

        System.out.println("用户名："+Username);
        System.out.println("密码："+Password);
        System.out.println("昵称："+NiekName);
        return "添加用户成功！";

    }


    @RequestMapping(value = "/v1/users/userlist")
    @ResponseBody
    public String userlist(){
        return "查询用户列表成功";
    }

    @RequestMapping(value = "/v1/users/user/delete")
    @ResponseBody
    public String userdelete(int Id){
        int id = Id;

        return "删除成功，用户id为"+id;

    }

    @RequestMapping(value = "/v1/users/user/update")
    @ResponseBody
    public String userupdate(UpdateDyo updateDyo){
        String id=updateDyo.getId();
        String username = updateDyo.getUsername();
        String password = updateDyo.getPassword();
        String nickname = updateDyo.getNickname();
        System.out.println("id:"+id);
        System.out.println("用户名:"+username);
        System.out.println("密码:"+password);
        System.out.println("昵称:"+nickname);

        return "更新成功";
    }
}
